<?php

namespace App\Models;

use App\Traits\WorkerMysqlConnect;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class u_all_record extends Model
{
    use HasFactory;
    use WorkerMysqlConnect;

    protected $table = 'u_all_record';

    protected $primaryKey = 'id';

    public static function getAllRecord($startPage=1,$limit=10)
    {
        return self::query()->select('*')
            ->offset(($startPage-1)*$limit)->limit($limit)
            ->orderByDesc('id')->get()->toArray();
    }


    public static function getRecordByIdAndShowhao($id,$showhao,$select = 'id,ju,userMax,moneyResultAll,room')
    {
        return toArray(self::query()->select(explode(',',$select))->where(compact('id','showhao'))->first());
    }
}
